package com.dtagri.fjwlw;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;

import com.dtagri.fjwlw.ui.MainActivity;
import com.dtagri.fjwlw.util.TDevice;

/**
 * @author wxjn
 * 
 */
public class AppStart extends Activity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// SystemTool.gc(this); //针对性能好的手机使用，加快应用相应速度

		final View view = View.inflate(this, R.layout.app_start, null);
		setContentView(view);

		int lastCode = AppContext.getLastCode();
		int curCode = TDevice.getVersionCode();
		if (curCode != lastCode) {
			AppContext.setLastCode(curCode);
			AppContext.cleanLoginInfo(AppContext.user);
		}

		// 渐变展示启动屏
		AlphaAnimation aa = new AlphaAnimation(0.5f, 1.0f);
		aa.setDuration(800);
		view.startAnimation(aa);
		aa.setAnimationListener(new AnimationListener() {
			@Override
			public void onAnimationEnd(Animation arg0) {
				redirectTo();
			}

			@Override
			public void onAnimationRepeat(Animation animation) {
			}

			@Override
			public void onAnimationStart(Animation animation) {
			}
		});
	}

	/**
	 * 跳转到...
	 */
	private void redirectTo() {
		Intent intent = new Intent(this, MainActivity.class);
		startActivity(intent);
		finish();
	}
}
